<?php

namespace app\logic\api;

class L_files
{
    /**
     * 获取文件列表
     * @param string $paramObj
     */
    public function showDir($paramObj = "")
    {
        $dataObj = paramsObj();
        $dataObj->request = paramsObj();
        $dataObj->data = paramsObj();
        $dataObj->data->use_trans = false;
        $dataObj->result = new \ArrayObject();

        $final_arr = logInit();
        if ($final_arr["error_no"] == 0) {
            $mixed = parseToArr($paramObj, "mixed", 0);
            $params = parseToArr($paramObj, "params", array());
            $messages = parseToArr($paramObj, "messages", array());
            $rules = array(
                'dir' => '',
                'level' => '',
                'isCheck' => '',
            );
            $paramsObj = paramsObj();
            $paramsObj->params = $params;
            $paramsObj->mixed = $mixed;
            $paramsObj->rules = $rules;
            $paramsObj->messages = $messages;
            $checkResult = app("verifyParam")::validatorRequest($paramsObj);
            if ($checkResult["error_no"] == 0) {
                $dataObj->request = $checkResult["result"];
            } else {
                $final_arr = logCallErrorMsg($final_arr, $checkResult);
            }
        }
        if ($final_arr["error_no"] == 0) {
            $dir=dstripslashes($dataObj->request->dir);
            $files=app("yifangZip")->files(str_replace("\\","/",$dir));
            $resourceDir="/static/admin";
            $html=app("yifangFormat")->showDir($files,$resourceDir,0,$dataObj->request->level,$dataObj->request->isCheck);  //转换成html
            $final_arr["result"] = $html;
        }
        return $final_arr;
    }
}